package com.baizhi.service.impl;

import com.baizhi.entity.User;
import com.baizhi.mapper.UserMapper;
import com.baizhi.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author longyang
 * @since 2022-01-11
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    public User selectUser(User user) {
        //条件构造器：用于构建sql条件
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
        // where username = "xiaohei" and password = "123456"
        queryWrapper.eq("username",user.getUsername()).eq("password",user.getPassword());
        //查询
        User newUser = userMapper.selectOne(queryWrapper);
        //返回user
        return newUser;
    }
}
